<?php 
$data = $mvc->getObject(TradesmanContentController::RESULT);
$projects = $mvc->getObject(CompanyService::COMPANY_PROJECT);
$certificates = $mvc->getObject(CompanyService::COMPANY_CARTIFICATES);
$references = $mvc->getObject(CompanyService::COMPANY_REFERENCES);
$feedbacks = $mvc->getObject(CompanyService::COMPANY_FEEDBACK);
$image_errors = $mvc->getObject(TradesmanContentController::IMAGE_ERROR);
$status = $mvc->getObject(TradesmanContentController::STATUS);
?>
<form action="/company-profile.html" method="post"  enctype="multipart/form-data">
<div class="unitABlock">
<?php if (isset($status)){?>
	<div class="itemOk">
		<p>_i18n{Successfully Saved.}</p>
	</div>
<?php } ?>
<?php if (isset($image_errors )){?>
	<div class="itemWarning">
		<ul>
			<?php foreach ($image_errors as $key => $value){?>
				<li><?php echo $value ?></li>
			<?php } ?>					
		</ul>
	</div>
<?php } ?>
	<div class="unitEqColumn">
		<dl class="itemForm">
			<dt>_i18n{Company Name}:</dt>
			<dd class="itemData"><?php echo $data[UsersService::COMPANY]?></dd>
		</dl>
		<dl class="itemForm">
			<dt>_i18n{Ust-ID}:</dt>
			<dd class="itemData"><?php echo $data[UsersService::VAT]?></dd>
		</dl>
		<dl class="itemForm">
			<dt>_i18n{Year}:</dt>
			<dd class="itemData"><?php echo $data[UsersService::COMPANY_YEAR]?></dd>
		</dl>
		<h3>_i18n{Contact}</h3>
		<div class="itemForm">
			<label>_i18n{Salutation}:</label>
			<div class="itemData">
				<select name="salutation">
					<?php if ($data[UsersService::SALUTATION]==NULL || $data[UsersService::SALUTATION]==0){?>
						<option value="0">_i18n{Please choose}</option>
						<option value="1">_i18n{Mr.}</option>
						<option value="2">_i18n{Ms.}</option>
						<?php } else { 
								if($data[UsersService::SALUTATION]==1) {?>
								<option value="1">_i18n{Mr.}</option>
								<option value="2">_i18n{Ms.}</option>
							<?php } else { ?>
								<option value="2">_i18n{Ms.}</option>
								<option value="1">_i18n{Mr.}</option>
					<?php } } ?>
				</select>
			</div>
		</div>
		<div class="itemForm">
			<label>_i18n{First Name}:</label>
			<div class="itemData">
				<input class="inpTxt" type="text" name="firstname" value="<?php echo $data[UsersService::FIRSTNAME]?>"/>
			</div>
		</div>
		<div class="itemForm">
			<label>_i18n{Last Name}:</label>
			<div class="itemData">
				<input class="inpTxt" type="text" name="lastname" value="<?php echo $data[UsersService::LASTNAME]?>"/>
			</div>
		</div>
		<div class="itemForm">
			<label>_i18n{Mobile Phone}:</label>
			<div class="itemData">
				<input class="inpTxt" type="text" name="phone" value="<?php echo $data[UsersService::PHONE]?>" />
			</div>
		</div>
		<div class="itemForm">
			<label>_i18n{E-Mail}:</label>
			<div class="itemData">
				<input class="inpTxt" type="text" name="email" value="<?php echo $data[UsersService::EMAIL]?>" />
			</div>
		</div>
	</div>
	
	<div class="unitEqColumn">
		<dl class="itemForm">
			<dt>_i18n{Street}:</dt>
			<dd class="itemData"><?php echo $data[UsersService::ADDRESS]?></dd>
		</dl>
		<dl class="itemForm">
			<dt>_i18n{ZIP}:</dt>
			<dd class="itemData"><?php echo $data[UsersService::ZIP]?></dd>
		</dl>
		<dl class="itemForm">
			<dt>_i18n{City}:</dt>
			<dd class="itemData"><?php echo $data[UsersService::LOCATION]?></dd>
		</dl>
		<dl class="itemForm">
			<dt>_i18n{State}:</dt>
			<dd class="itemData"><?php echo $data[UsersService::REGION]?></dd>
		</dl>
		<dl class="itemForm">
			<dt>_i18n{Country}:</dt>
			<dd class="itemData"><?php echo $data[CountryService::COUNTRY_NAME]?></dd>
		</dl>
		<dl class="itemForm">
			<dt>_i18n{Homepage}:</dt>
			<dd class="itemData"><?php echo $data[RegionService::REGION_NAME]?></dd>
		</dl>
	</div>
	<div class="unitBtn">
		<button name="personalSbm"><span><strong>_i18n{Save}</strong></span></button>
	</div>
</div>
<h2>_i18n{Profile photo}</h2>
<div class="unitABlock">
	<div class="unitSnColumn">
		<div class="itemForm">
			<img alt="" src="/<?php echo $data[UsersService::AVATAR] ?>" />
		</div>
		<div class="itemForm">
			<input type="file" name="file" />
			<input type="hidden" name="id" value="<?php echo $data[UsersService::ID]?>"/>
			<button name="pctSbm"><span><strong>_i18n{Upload image}</strong></span></button>
		</div>
	</div>
</div>
<h2>_i18n{Company Info}</h2>
<div class="unitABlock">
	<div class="unitInfo">
		<textarea class="areaTxt" rows="10" cols="103" name="company_desc"><?php echo $data[UsersService::COMPANY_DESC] ?></textarea>
	</div>
	<div class="unitBtn">
		<button name="companyInfoSbm"><span><strong>_i18n{Save}</strong></span></button>
	</div>
</div>
<ul class="viewIList">
	<li class="itemNewI"><a href="/new-profile-image.html" class="linkLight" title="_i18n{Add image}">_i18n{Add image}</a></li>
	<li class="itemNewP"><a href="/new-profile-project.html" class="linkLight" title="_i18n{Add project}">_i18n{Add project}</a></li>
	<li class="itemNewS"><a href="/new-profile-certificate.html" class="linkLight" title="_i18n{Add certificate}">_i18n{Add certificate}</a></li>
</ul>
<h2>_i18n{Reference}</h2>
<div class="unitABlock">
	<div class="unitRef">
	<!-- $references -->
		<input type="hidden" name="deleteReferences" />
		<h3>_i18n{Reference images}</h3>

<?php if(isset($references)&&$references!=null){
	foreach($references as $key =>$reference){?>		
		<div class="unitImg">
			<div class="innerP">
				<img src="<?php echo $reference[UploadsService::PATH]?>" alt="<?php echo $reference[CompanyService::REFERENCE_TITLE]?>" />
				<p><?php echo $reference[CompanyService::REFERENCE_TITLE]?></p>
			</div>
			<div class="linkDelete">
				<a href="#" rel="<?php echo $reference[CompanyService::ID]?>" title="Remove">Remove</a>
			</div>
		</div>
<?php } } else { ?>
		<div class="unitProject">
			<div class="innerP">
				_i18n{Sorry, no reference project yet.}
			</div>
		</div>
<?php } ?>
	</div>
	<div class="unitRef">
		<input type="hidden" name="deleteProject" />
		<h3>_i18n{Reference project}</h3>
<?php if(isset($projects)&&$projects!=null){
	foreach($projects as $key =>$project){?>
		<div class="unitProject">
			<div class="innerP">
				<a href="<?php echo $project[CompanyService::PROJECT_URL]?>" title="<?php echo $project[CompanyService::PROJECT_URL]?>"><?php echo $project[CompanyService::PROJECT_URL]?></a> - <?php echo $project[CompanyService::PROJECT_TITLE]?>
			</div>
			<div class="linkDelete">
				<a href="#" rel="<?php echo $project[CompanyService::ID]?>" title="_i18n{Remove}">_i18n{Remove}</a>
			</div>
		</div>
<?php } } else { ?>
		<div class="unitProject">
			<div class="innerP">
				_i18n{Sorry, no reference project yet.}
			</div>
		</div>
<?php } ?>
	</div>
	<div class="unitRef">
		<input type="hidden" name="deleteCertificates" />
		<h3>_i18n{Certificates}</h3>
<?php if(isset($certificates)&&$certificates!=null){
	foreach($certificates as $key =>$certificate){?>
		<div class="unitCertificate">
			<div class="innerP">
				<a href="<?php echo $certificate[UploadsService::PATH]?>" title="<?php echo $certificate[CompanyService::CARTIFICATES_TITLE]?>"><?php echo $certificate[CompanyService::CARTIFICATES_TITLE]?></a>
			</div>
			<div class="linkDelete">
				<a href="#" rel="<?php echo $certificate[CompanyService::ID]?>" title="_i18n{Remove}">_i18n{Remove}</a>
			</div>
		</div>
<?php } } else { ?>
		<div class="unitCertificate">
			<div class="innerP">
				_i18n{Sorry, no certificates yet.}
			</div>
		</div>
<?php } ?>
	</div>
</div>
<h2>_i18n{Company Comments}</h2>
<div class="unitABlock unitABlockLast">
	<div class="viewDComment">
		<?php
if(isset($feedbacks)&&$feedbacks!=null){
	foreach($feedbacks as $key =>$feedback){?>
		<div class="unitDComment <?php echo ($key%2) == 0 ? 'unitOdd':null;?>">
			<div class="itemTitle">
				<h4><?php echo $feedback[UsersService::USERNAME] ?></h4><span class="itemDate"><?php echo $feedback[CompanyService::DATE] ?></span>
			</div>
			<div class="itemText">
				<p><?php echo $feedback[CompanyService::COMMENT] ?></p>
				<p><strong>_i18n{Order}:</strong> <a href="/view-order.html?id=<?php echo $feedback[OrdersService::HASH] ?>" title="<?php echo $feedback[OrdersService::ORDER_NAME] ?>"><?php echo $feedback[OrdersService::ORDER_NAME] ?></a></p>
			</div>
			<div class="itemRating">
				<div class="unitRating">
					<div class="simpleRating">
						<ul>
							<li class="itemCurrent" style="width:<?php echo $feedback[CompanyService::VOTE] ?>%"></li>
						</ul>
						<p><strong>1</strong> (<?php echo $feedback[CompanyService::VOTE] ?>% _i18n{positiv}) <a href="#" title="Extended">Extended</a></p>
					</div>
					<div class="extendRating">
						<dl>
							<dt>_i18n{Quality of work}:</dt>
							<dd><span class="itemCurrent" style="width:<?php echo $feedback[CompanyService::VOTE1] ?>%"></span></dd>
						</dl>
						<dl>
							<dt>_i18n{Reliability}:</dt>
							<dd><span class="itemCurrent" style="width:<?php echo $feedback[CompanyService::VOTE2] ?>%"></span></dd>
						</dl>
						<dl>
							<dt>_i18n{Cleanliness}:</dt>
							<dd><span class="itemCurrent" style="width:<?php echo $feedback[CompanyService::VOTE3] ?>%"></span></dd>
						</dl>
						<dl>
							<dt>_i18n{Price/Performance}:</dt>
							<dd><span class="itemCurrent" style="width:<?php echo $feedback[CompanyService::VOTE4] ?>%"></span></dd>
						</dl>
						<dl>
							<dt>_i18n{Project delivered}:</dt>
							<dd><span class="itemCurrent" style="width:<?php echo $feedback[CompanyService::VOTE5] ?>%"></span></dd>
						</dl>
						<dl>
							<dt>_i18n{Consulting Services}:</dt>
							<dd><span class="itemCurrent" style="width:<?php echo $feedback[CompanyService::VOTE6] ?>%"></span></dd>
						</dl>
						<p><a href="#" title="Avarage">Avarage</a></p>
					</div>
				</div>
			</div>
		</div>
		<?php } 
} else { ?>
		<div class="unitDComment unitOdd">
			<div class="itemText">
				<p>_i18n{Sorry, no comments yet.}</p>
			</div>
		</div>
	<?php } ?>
	</div>
</div>
</form>